<?php
    class user_Model extends dl_connect{
        
        function __construct(){
            $this->Connect();
        }
        
        /**
         * Them record cho bang user
         * @return int
         * */
        public function add($tendangnhap, $matkhau,$fullname,$email,$diachi,$sdt){
            $this->ExecuteSQL("INSERT INTO `dulich`.`user` (`name` ,`pass`,`ten` ,`email`,`diachi` ,`sdt`)
                                VALUES ('{$tendangnhap}', MD5('{$matkhau}'),'{$fullname}','{$email}','{$diachi}','{$sdt}' )");
            if(mysql_affected_rows($this->con)>0){
                return 1;
            }else{
                return 0;
            }
        }
        
        public function edit($username, $password, $role){
            $this->ExecuteSQL("UPDATE `dulich`.`user` SET `pass` = MD5( '{$password}' ) ,
                                        `role` = '{$role}' 
                                WHERE `user`.`name` = '{$username}'");
            if(mysql_affected_rows($this->con)>0){
                return 1;
            }else{
                return 0;
            }
        }
        
        public function delete($id){
            $this->ExecuteSQL("delete from dulich.user where name = '{$id}'");
            if(mysql_affected_rows($this->con)>0){
                return 1;
            }else{
                return 0;
            }
        }
         
    }
?>